Skip to content

fix: package eigdemo/tripleangledemo/twistdemo entry points correctly - #600

Merged
petercorke merged 3 commits into
mainfrom
feat/package-demo-scripts
Aug 16, 2026
Merged

petercorke merged 3 commits into
mainfrom
feat/package-demo-scripts

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • The three demo console-scripts (eigdemo, tripleangledemo, twistdemo) pointed at roboticstoolbox.examples.*, a module path that hasn't existed since the demos were relocated to a top-level examples/ dir outside the packaged tree (wheel.packages = ["src/roboticstoolbox"]) -- every installed entry point 404'd at import time.
  • Moved the three scripts into src/roboticstoolbox/demo/ (mirrors the existing bin/ pattern used by rtbtool), updated [project.scripts] accordingly.
  • twistdemo.py wrapped in main() (was flat top-level code).
  • tripleangledemo.py/twistdemo.py: replaced while True: env.step(0) with env.run(duration=...) -- also fixes a real bug, the raw loop never noticed the browser tab closing and spun forever; run() has disconnect-awareness built in. A --test flag bounds the duration for smoke testing instead of running until disconnect.
  • eigdemo.py: fixed -h/--help (compared the whole sys.argv list against a string, could never match); added the repo's standard hashbang line.
  • Fixed a matching stale coverage.run.omit path in pyproject.toml (same never-existed src/roboticstoolbox/examples/*).
  • Added tests/test_demo.py: smoke tests for all three entry points. The two Swift-based ones use SWIFT_HEADLESS=1 (new in jhavl/swift#122, merged) + --test to run headless with a bounded duration; skipped when swift isn't installed (matches test_backend_capabilities.py's existing pattern), so test-core (no swift) still passes.

Test plan

  • All three entry points run manually post-reinstall: eigdemo (default + --help + custom matrix), tripleangledemo --test, twistdemo --test (both headless)
  • pytest tests/test_demo.py: 5/5 pass
  • Full suite (pytest tests/ --ignore=tests/test_blocks.py): 716 passed, 3 skipped -- unchanged from main (confirmed via stash-compare; pre-existing spatialgeometry deprecation warnings noted separately, not touched here)

…box.demo

The three demo console-scripts (pyproject.toml [project.scripts]) pointed
at roboticstoolbox.examples.*, a module path that hasn't existed since the
demos were relocated to a top-level examples/ dir outside the packaged
src/roboticstoolbox tree (wheel.packages = ["src/roboticstoolbox"]) --
every installed entry point 404'd at import time.

- Move the three scripts into src/roboticstoolbox/demo/ (new package,
  mirroring the existing bin/ pattern used by rtbtool).
- twistdemo.py: wrap its previously flat top-level code in main(), matching
  the other two.
- tripleangledemo.py/twistdemo.py: replace `while True: env.step(0)` with
  `env.run(duration=...)` -- besides enabling a --test smoke-test mode
  (bounded duration instead of running forever), this is a genuine fix on
  its own: the raw loop never noticed the browser tab closing, so closing
  it just left the process spinning forever; run() already has
  disconnect-awareness built in.
- eigdemo.py: fix `-h`/`--help`, which compared the whole sys.argv list
  against a string and so could never match; add the repo's standard
  hashbang line.
- pyproject.toml: repoint the three [project.scripts] entries; fix the
  matching coverage omit path (also stale, pointing at the same
  never-existed src/roboticstoolbox/examples/*).
eigdemo runs to completion under MPLBACKEND=Agg as-is. tripleangledemo
and twistdemo need --test (bounds env.run() to a short sim-time duration)
plus SWIFT_HEADLESS=1 (swift jhavl/swift#122) to run without a browser;
skipped when swift isn't installed, matching test_backend_capabilities.py's
existing swift-optional pattern.
@petercorke
petercorke force-pushed the feat/package-demo-scripts branch from 829cc27 to e0de788 Compare August 16, 2026 22:50
eigdemo() prints λ1/λ2 (literal Greek chars). Windows defaults stdout
to the legacy cp1252 console codepage whenever it isn't a real console
-- piped/redirected output included -- and cp1252 has no mapping for
λ, so print() raised UnicodeEncodeError. Caught by test_demo.py's new
subprocess-based smoke tests on windows-latest (both 3.10 and 3.11):
the exact case of capturing eigdemo's stdout through a pipe. A real
Windows user piping or redirecting eigdemo's output would hit the same
crash outside of CI.

sys.stdout.reconfigure(encoding="utf-8") (3.7+) forces UTF-8
regardless of the console's codepage.
@petercorke
petercorke merged commit b19eaa6 into main Aug 16, 2026
16 checks passed
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (4fd2dff) to head (30df358).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #600   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        142     142           
  Lines      13891   13891           
=====================================
  Misses     13891   13891           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot mentioned this pull request Aug 16, 2026
@petercorke
petercorke deleted the feat/package-demo-scripts branch October 22, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant